package com.tinshow.service.index.impl;

import com.tinshow.config.utils.ImageUtil;
import com.tinshow.dao.article.MusicMapper;
import com.tinshow.model.article.Music;
import com.tinshow.service.index.MusicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by libo4 on 2017/5/29.
 */
@Service
public class MusicServiceImpl implements MusicService{

    @Autowired
    MusicMapper musicMapper;

    @Override
    public void insertMusic(Music music) {
        musicMapper.insertSelective(music);
    }

    @Override
    public Music getMusicForUrl(String url) {
        return null;
    }

    @Override
    @Cacheable
    public List<Music> selectAllMusic() {
        List<Music> musicList = musicMapper.selectAllMusic();
        for (Music m: musicList) {
            m.setPicUrl(ImageUtil.getPic100ByEcho(m.getPicUrl()));
        }
        return musicList;
    }
}
